package com.start.workflow.act;

import com.alibaba.fastjson2.JSONObject;
import com.start.common.entity.StartBaseUser;
import com.start.workflow.entity.StartActModelConfig;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.activiti.bpmn.model.UserTask;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.task.Task;

import java.util.List;
import java.util.Map;

@Data
public class StartProcTaskDef {

    @Schema(name = "节点定义key")
    private String taskDefKey;
    @Schema(name = "节点名称")
    private String taskName;
    @Schema(name = "节点配置信息")
    private Map<String, StartActModelConfig> taskConfig;

    @Schema(name = "表单配置信息")
    private StartActModelConfig taskFormConfig;
    @Schema(name = "候选人配置")
    private StartActModelConfig candidateUserConfig;

    @Schema(name = "表单配置信息")
    private JSONObject nodeFormOption;
    @Schema(name = "节点候选处理人")
    private List<StartBaseUser> candidateUsers;

    public StartProcTaskDef() {

    }

    public StartProcTaskDef(Task task) {
        taskDefKey = task.getTaskDefinitionKey();
        taskName = task.getName();
    }

    public StartProcTaskDef(UserTask userTask) {
        taskDefKey = userTask.getId();
        taskName = userTask.getName();
    }

    public StartProcTaskDef(HistoricActivityInstance activityInstance) {
        setTaskDefKey(activityInstance.getActivityId());
        setTaskName(activityInstance.getActivityName());
    }
}
